<?php

function getWalkScore($lat, $lon, $address)
{
	$address=urlencode($address);
	$url = "http://api.walkscore.com/score?format=xml&address=$address";
	$url .= "&lat=$lat&lon=$lon&wsapikey=60b39facc931c1079d5b0478c78f0358";
	$str = @file_get_contents($url); 
	return $str; 
}

$lat = $_GET['lat']; 
$lon = $_GET['lon']; 
//$address = null;//stripslashes($_GET['address']);
$xml = simplexml_load_string(getWalkScore($lat,$lon, null));
//echo $json;
//$array = new array(); 
foreach( $xml->children() as $child )
{
	$array[ $child->getName() ] = $child;
}
echo '<p>';
/*
echo '<a href="'. $array['ws_link'].'" style="text-decoration: none;">';
echo '<img src="'.$array['logo_url'].'" />';
echo '<span style="margin-left: 7px; font-weight: bold; font-size: 15px; position: relative; top: -2px; color: #B14900; cursor: pointer; line-height: 17px; font-family: Verdana,Arial,Helvetica,sans-serif; text-align: center;">'. $array['walkscore'] .'</span>';
echo '</a>';
echo '<span style="position: relative; top: -5px; margin-left: 4px;">';
echo '<a href=​"http:​/​/​www.walkscore.com/​how-it-works.shtml">';
echo '<img src="'.$array['more_info_icon'].'" />';
echo '</a>';
echo '</span>';
/*/
echo 'Walk score:'. $array['walkscore'];
//*/
echo '</p>';

?>

